package com.employee.controller;

import com.employee.pojo.dto.UpdatePosDto;
import com.employee.pojo.entry.Leave;
import com.employee.pojo.entry.LeaveType;
import com.employee.pojo.result.Result;
import com.employee.service.LeaveService;
import com.employee.service.LeaveTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
public class LeaveController {
    @Autowired
    private LeaveTypeService leaveTypeService;
    @Autowired
    private LeaveService leaveService;

    // LeaveType表的增删改查接口
    @GetMapping("/getLeave")
    public Result<List<LeaveType>> getLeave() {
        List<LeaveType> LeaveType = leaveTypeService.getLeave();
        return Result.success(LeaveType);
    }
    @PostMapping("/addLeave")
    public Result<LeaveType> addLeave(@RequestBody LeaveType leave) {
        leaveTypeService.addLeave(leave);
        return Result.success();
    }
    @PostMapping("/updateLeave")
    public Result updateLeave(@RequestBody LeaveType leave) {
        leaveTypeService.updateLeave(leave);
        return Result.success();
    }
    @GetMapping("/deleteLeave/{id}")
    public Result deleteLeave(@PathVariable int id) {
        leaveTypeService.deleteLeave(id);
        return Result.success();
    }

    //接下来是Leave表的增删改查接口
    @GetMapping("/getLeaveList")
    public Result<List<Leave>> getLeaveList() {
        List<Leave> LeaveList = leaveService.getLeaveList();
        return Result.success(LeaveList);
    }
}
